
<div id="toolbar-box">
  <div class="t">
    <div class="t">
      <div class="t"></div>
    </div>
  </div>
  <div class="m">
    <div id="toolbar" class="toolbar">
        <table class="toolbar"><tbody><tr>
        	<td id="toolbar-save" class="button"><a class="toolbar" onClick="javascript: submitbutton('save'); return false;" href="javascript:void(0);"> <span title="Save" class="icon-32-save"> </span> Save </a> </td>
	        <td id="toolbar-cancel" class="button"><a class="toolbar" onClick="javascript: submitbutton('cancel'); return false;" href="javascript:void(0);"> <span title="Cancel" class="icon-32-cancel"> </span> Cancel </a> </td>
        </tr></tbody></table>
    </div>
    <div class="header icon-48-user">Chi tiết hóa đơn</div>
    <div class="clr"></div>
  </div>
  <div class="b">
    <div class="b">
      <div class="b"></div>
    </div>
  </div>
</div>
<div class="clr"></div>
<div id="submenu-box">
  <div class="t">
    <div class="t">
      <div class="t"></div>
    </div>
  </div>
  <div class="m">
    <ul id="submenu">
      <li> <a class="active" href="<?php echo $this->Html->url(array('controller'=>'orders', 'action'=>'index')); ?>">Quản lý đơn đặt hàng</a> </li>
      <li> <a href="<?php echo $this->Html->url(array('controller'=>'transport_fee', 'action'=>'index')); ?>">Phí vận chuyển</a> </li>
      <li> <a href="<?php echo $this->Html->url(array('controller'=>'reports', 'action'=>'index')); ?>">Báo cáo doanh thu</a> </li>
    <div class="clr"></div>
  </div>
  <div class="b">
    <div class="b">
      <div class="b"></div>
    </div>
  </div>
</div>
<div id="element-box">
  <div class="t">
    <div class="t">
      <div class="t"></div>
    </div>
  </div>
  <div class="m">
<script language="javascript" type="text/javascript">
	function submitbutton(pressbutton) {
		var form = document.adminForm;
		if (pressbutton == 'cancel') {
			submitform( pressbutton );
			return;
		}
                submitform( pressbutton );
	}
        $(document).ready(function(){
            $( "#OrderBuyerBirthday" ).datepicker({
                dateFormat: 'dd-mm-yy',
                changeMonth: true,
                changeYear: true,
                yearRange: '1900:2090',
            });
            $('#OrderTimeSend').datetimepicker( {
                    changeMonth: true,
                    showHour: true,
                    dateFormat: 'dd-mm-yy',
                    changeYear: true,
                    yearRange: '1900:2090',
            });
            $('#select_buyer_birthday').click(function(){
                $('#OrderBuyerBirthday').datepicker( "show" );
            });
            $('#select_time_send').click(function(){
                $('#OrderTimeSend').datetimepicker('show');
            });
            
        });
</script>
    <?php echo $this->Form->create('Order', array('type'=>'file', 'style'=> 'clear: both;', 'name'=>'adminForm', 'id'=>'adminForm')); ?>
      <div class="col">
        <fieldset class="adminform">
            <legend>thông tin đặt hàng</legend>
            <table cellspacing="1" class="admintable">
                <tbody>
                    <tr>
                      <td width="150" class="key">Mã Hóa Đơn
                      </td>
                      <td width="700">
                          <strong><?php echo 'H3L' . str_pad($data['Order']['id'], 5, '0', STR_PAD_LEFT); ?></strong>
                      </td>
                    </tr>
                    <tr>
                      <td width="150" class="key">Phí mua hàng
                      </td>
                      <td width="700">
                          <strong><?php echo number_format(sprintf("%01.2f", $data['Order']['total_price_order']),0, ',', '.'); ?></strong>
                          <?php echo $this->Form->input('total_price_order', array('type'=>'hidden')); ?>
                      </td>
                    </tr>
                    <tr>
                      <td width="150" class="key">Phí vận chuyển
                      </td>
                      <td width="700">
                          <?php if(is_null($data['Order']['total_price_transport'])){ ?>
                          <strong>Call</strong>
                          <?php }else{ ?>
                          <strong><?php echo number_format(sprintf("%01.2f", $data['Order']['total_price_transport']),0, ',', '.'); ?></strong>
                          <?php } ?>
                      </td>
                    </tr>
                    <tr>
                      <td width="150" class="key">Tổng tiền
                      </td>
                      <td width="700">
                          <strong><?php echo number_format(sprintf("%01.2f", intval($data['Order']['total_price_order'] + $data['Order']['total_price_transport'])),0, ',', '.'); ?></strong>
                      </td>
                    </tr>
                    <tr>
                      <td width="150" class="key"><label for="transport_type">Kiểu vận chuyển</label>
                      </td>
                      <td>
                            <?php echo $this->Form->select('transport_type',$transport_type, array('empty'=> false,'secure'=>true)); ?>
                      </td>
                    </tr>

                    <tr>
                      <td width="150" class="key"><label for="payment_type">Kiểu thanh toán</label>
                      </td>
                      <td>
                            <?php echo $this->Form->select('payment_type',$payment_type, array('empty'=> false,'secure'=>true)); ?>
                      </td>
                    </tr>
                    <tr>
                      <td width="150" class="key"><label for="drawee">Người thanh toán tiền</label>
                      </td>
                      <td>
                            <?php echo $this->Form->select('drawee',$drawee, array('empty'=> false,'secure'=>true)); ?>
                      </td>
                    </tr>
                    <tr>
                      <td width="150" class="key"><label for="payment_type">Tình trạng thanh toán</label>
                      </td>
                      <td>
                            <?php echo $this->Form->select('payment_status',$payment_status, array('empty'=> false,'secure'=>true)); ?>
                      </td>
                    </tr>
                    <tr>
                      <td width="150" class="key"><label for="transport_status">Tình trạng giao hàng</label>
                      </td>
                      <td>
                            <?php echo $this->Form->select('transport_status',$transport_status, array('empty'=> false,'secure'=>true)); ?>
                      </td>
                    </tr>
                    <tr>
                      <td width="150" class="key"><label for="time_send">Thời gian giao hàng</label>
                      </td>
                      <td>
                            <?php echo $this->Form->input('time_send', array('type'=>'text', 'value'=>$data[0]['time_send'] ,'class'=>'inputbox', 'size'=> 30, 'label'=> false, 'div'=>false)); ?>

                            <a href="javascript:void(0);" id="select_time_send">
                                <?php echo $this->Html->image('ico_calendar.gif'); ?>
                            </a>
                      </td>
                    </tr>
                    <tr>
                      <td width="150" class="key"><label for="extra_content">Nội dung</label>
                      </td>
                      <td>
                            <?php echo $this->Form->input('extra_content', array('class'=>'inputbox','type'=>'textarea','cols'=>60, 'rows'=>3, 'size'=> 40, 'label'=> false, 'div'=>false)); ?>
                      </td>
                    </tr>
                    <tr>
                      <td width="150" class="key"><label for="order_content">Nội dung đơn hàng</label>
                      </td>
                      <td>

                          <table width="100%" class="adminlist" align="center">
                              <thead>
                                  <tr>
                                      <th width="10%" class="title">ID</th>
                                      <th width="30%" class="title">Tên Sản phẩm</th>
                                      <th width="30%" class="title">Lọai</th>
                                      <th width="5%"  class="title">Số Lương</th>
                                      <th class="title" width="25%">Thông tin thêm</th>
                                  </tr>
                              </thead>
                              <tbody>
                               <?php
                                $product_in_order   = unserialize($data['Order']['order_content']);
                                foreach($product_in_order AS $row):
                                ?>
                               <tr>
                                      <td align="center"><?php echo $row['product_id']; ?></td>
                                      <td align="center"><?php echo $row['product_name']; ?></td>
                                      <td align="center"><?php echo $product_type[$row['product_type']]; ?></td>
                                      <td align="center"><?php echo $row['quantity']; ?></td>
                                      <td align="center">
                                          <?php if(is_array($row['extra'])): ?>
                                            <?php if(isset ($row['extra']['ties'])): ?>
                                                <p>Ties: <?php echo $row['extra']['ties']['name']; ?></p>
                                            <?php endif; ?>
                                            <?php if(isset ($row['extra']['text'])): ?>
                                                <p>Text: <?php echo $row['extra']['text']['name']; ?></p>
                                            <?php endif; ?>
                                          <?php endif; ?>
                                      </td>
                               </tr>
                               <?php endforeach; ?>
                              </tbody>
                          </table>
                      </td>
                    </tr>
                </tbody>
            </table>
        </fieldset>
        <fieldset class="adminform">
            <legend>thông tin người mua</legend>
            <table cellspacing="1" class="admintable">
               <tbody>
                <tr>
                  <td width="150" class="key"><label for="buyer_name">Tên</label>
                  </td>
                  <td>
                        <?php echo $this->Form->input('buyer_name', array('class'=>'inputbox', 'size'=> 40, 'label'=> false, 'div'=>false)); ?>
                  </td>
                </tr>
                <tr>
                  <td width="150" class="key"><label for="buyer_phone">Điện thoại</label>
                  </td>
                  <td>
                        <?php echo $this->Form->input('buyer_phone', array('class'=>'inputbox', 'size'=> 20, 'label'=> false, 'div'=>false)); ?>
                  </td>
                </tr>
                <tr>
                  <td width="150" class="key"><label for="buyer_address">Địa chỉ</label>
                  </td>
                  <td>
                        <?php echo $this->Form->input('buyer_address', array('class'=>'inputbox', 'size'=> 100, 'label'=> false, 'div'=>false)); ?>
                  </td>
                </tr>
                <tr>
                  <td width="150" class="key"><label for="buyer_email">Email</label>
                  </td>
                  <td>
                        <?php echo $this->Form->input('buyer_email', array('class'=>'inputbox', 'size'=> 50, 'label'=> false, 'div'=>false)); ?>
                  </td>
                </tr>
                <tr>
                  <td width="150" class="key"><label for="buyer_sex">Giới tính</label>
                  </td>
                  <td>
                        <?php echo $this->Form->select('buyer_sex',$sex_list, array('empty'=> false,'secure'=>true)); ?>
                  </td>
                </tr>
                <tr>
                  <td width="150" class="key"><label for="buyer_birthday">Sinh nhật</label>
                  </td>
                  <td>
                        <?php echo $this->Form->input('buyer_birthday', array('type'=>'text', 'value'=>$data[0]['buyer_birthday'] ,'class'=>'inputbox', 'size'=> 20, 'label'=> false, 'div'=>false)); ?>
                        
                        <a href="javascript:void(0);" id="select_buyer_birthday">
                            <?php echo $this->Html->image('ico_calendar.gif'); ?>
                        </a>
                  </td>
                </tr>

              </tbody>
            </table>
        </fieldset>
        <fieldset class="adminform">
        <legend>thông tin người nhận</legend>
        <table cellspacing="1" class="admintable">
          <tbody>
            <tr>
              <td width="150" class="key"><label for="receiver_name">Tên</label>
              </td>
              <td>
                    <?php echo $this->Form->input('receiver_name', array('class'=>'inputbox', 'size'=> 40, 'label'=> false, 'div'=>false)); ?>
              </td>
            </tr>
            <tr>
              <td width="150" class="key"><label for="receiver_phone">Điện thoại</label>
              </td>
              <td>
                    <?php echo $this->Form->input('receiver_phone', array('class'=>'inputbox', 'size'=> 25, 'label'=> false, 'div'=>false)); ?>
              </td>
            </tr>
            <tr>
              <td width="150" class="key"><label for="receiver_address">Địa chỉ</label>
              </td>
              <td>
                    <?php echo $this->Form->input('receiver_address', array('class'=>'inputbox', 'size'=> 100, 'label'=> false, 'div'=>false)); ?>
              </td>
            </tr>
                <tr>
                  <td width="150" class="key"><label for="receiver_sex">Giới tính</label>
                  </td>
                  <td>
                        <?php echo $this->Form->select('receiver_sex',$sex_list, array('empty'=> false,'secure'=>true)); ?>
                  </td>
                </tr>
                <tr>
                  <td width="150" class="key"><label for="receiver_district">Quận</label>
                  </td>
                  <td>
                        <?php echo $this->Form->select('receiver_district', $district_list, array('empty'=> true,'secure'=>true)); ?>
                  </td>
                </tr>
          </tbody>
        </table>
        </fieldset>
      </div>
      <div class="clr"></div>
      <?php echo $this->Form->input('id', array('type'=>'hidden')); ?>
      <input type="hidden" name="task" value="" />
    </form>
    <div class="clr"></div>
  </div>
  <div class="b">
    <div class="b">
      <div class="b"></div>
    </div>
  </div>
</div>
